/*
 * @Author: szx
 * @Date: 2022-03-10 14:15:53
 * @LastEditTime: 2022-03-10 14:23:56
 * @Description:
 * @FilePath: \leetcode\1-99\88\88.js
 */
/**
 * @param {number[]} nums1
 * @param {number} m
 * @param {number[]} nums2
 * @param {number} n
 * @return {void} Do not return anything, modify nums1 in-place instead.
 */
var merge = function (nums1, m, nums2, n) {
    for (let i = 0; i < n; i++) nums1[i + m] = nums2[i];
    return nums1.sort((a, b) => a - b);
};

var merge = function (nums1, m, nums2, n) {
    let x = m - 1,
        y = n - 1;
    for (let i = nums1.length - 1; i >= 0; i--) {
        if (x >= 0 && y >= 0) nums1[i] = nums1[x] >= nums2[y] ? nums1[x--] : nums2[y--];
        else if (y >= 0) {
            nums1[i] = nums2[y--];
        } else break;
    }
    return nums1;
};
